<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<link href="${ctx}/css/main/base.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/css/main/main.css" rel="stylesheet" type="text/css" />
<style type="text/css">

#newPreview
{
    filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);
}
-->
</style>
<script src="scripts/inframe.js"></script>
<body>
<div id="info"><font color="red">${info}</font></div>
<form action="${ctx}/title/title_create.action" method="post"  enctype="multipart/form-data">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab_m">
  <tr>
    <td colspan="2" class="zctop"><span class="font14 zc_bt">增加栏目主分类</span></td>
    </tr>
  <tr>
    <td class="w1">栏目编号：</td>
    <td class="w2 left"><input type="text" name="title.titleCode" class="fl_l"/> 编号请尽量间隔开，2位数字<div id="errCode"></div></td>
  </tr>
  <tr>
    <td class="w1">栏目名称：</td>
    <td class="w2 left"><input type="text" name="title.titleName" class="fl_l"/><div id="errName"></div></td>
  </tr>
  <tr>
    <td class="w1">栏目注释：</td>
    <td class="w2 left"><input type="text" name="title.titleNameEn" class="fl_l"/><div id="errNameEn"></div></td>
  </tr>
	<tr>
		<td class="w1" >
			栏目状态：
		</td>
		<td class="w2">
			<select id="titleFlag" name="title.titleFlag" class="fl_l">	    				
				<option value="0">有效</option>
				<option value="1">无效</option>
			</select>
			<div id="errTitleFlag"></div>
		</td>
	</tr>	  
  <tr>
    <td colspan="2" class="hei_1">
    <input type="button" onclick="addTitle();" value="确 定" class="log_f zc_b">
	<input type="button" onclick="returnTitle();" value="返 回" class="log_f zc_b">
    </td>
    </tr>
</table>
</form>
</body>
</html>
<script type="text/javascript" src="${ctx}/scripts/commons/validation.js"></script>
<script type="text/javascript">

	function addTitle(){
		var code = document.getElementById("title.titleCode").value ;
		var name = document.getElementById("title.titleName").value;		
		var nameEn = document.getElementById("title.titleNameEn").value;
		var titleFlag = document.getElementById("titleFlag").value;
	var flag1 = /^[0-9]{2}$/;
	if(!flag1.test(code)){
		document.getElementById("errCode").innerHTML = "<font color='red'>编号必须是两位数字</font>";
	   return false;
	}
	if(code.length > 2){
		document.getElementById("errCode").innerHTML = "<font color='red'>编号必须是两位数字</font>";
	   return false;
	}
	if(code.length == 0 && name.length == 0){
	   document.getElementById("errName").innerHTML = "<font color='red'>不能添加空的栏目节点</font>";
	   return false;
	}
	if(name == '' || name.length == 0){
	   document.getElementById("errName").innerHTML = "<font color='red'>栏目名称不能为空</font>";
	   return false;
	}
	if(nameEn == '' || nameEn.length == 0){
	   document.getElementById("errNameEn").innerHTML = "<font color='red'>栏目英文名称不能为空</font>";
	   return false;
	}
	if(name.length > 0 && hasSpecialChart(name)){
			document.getElementById("errName").innerHTML = "<font color='red'> 栏目名称不能有特殊字符!</font>";
			return false;
		}
	if(name.length > 50){
	   document.getElementById("errName").innerHTML = "<font color='red'>栏目名称不能超过50</font>";
	   return false;
	}
	if(nameEn.length > 50){
	   document.getElementById("errNameEn").innerHTML = "<font color='red'>栏目英文名称不能超过50</font>";
	   return false;
	}
	if(name.length > 0 && (code.length == 0)){
	   document.getElementById("errName").innerHTML = "<font color='red'>栏目编号不能为空</font>";
	   return false;
	}
	if (titleFlag.length == 0) {
			document.getElementById("errTitleFlag").innerHTML = "<font color='red'> 请选择栏目状态！</font>";
			return false;
	}	 
	 document.forms[0].submit();
		 
	}
	
	function returnTitle(){
		document.getElementById("title.titleCode").value = "";
		document.getElementById("title.titleName").value = "";
		document.getElementById("title.titleImage").value = "";
		history.go(-1);
	}
	function PreviewImg(imgFile){
	    //新的预览代码，支持 IE6、IE7。
	    var newPreview = document.getElementById("newPreview");
	    newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
	    if(imgFile.value)
  			newPreview.style.height = "71px";
		if(newPreview.innerHTML.length > 0 ){
			newPreview.innerHTML = "";
		}				
	}	
</script>
